package com.destroyer.core.entity.userInfo.bo;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.destroyer.core.entity.userInfo.UserInfoPO;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.StringUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
import com.destroyer.core.entity.base.BaseBO;
import com.destroyer.common.entity.system.ResultEnum;
import com.destroyer.common.exception.ServiceException;
import com.destroyer.common.util.Func;
import com.destroyer.core.util.MpSqlWrapperUtils;

/**
 * 标题：用户信息(查询业务对象)
 * 说明：用户信息(查询业务对象),常用于查询入参
 * 时间：2024-2-26
 * 作者：admin
 */
@Data
@Accessors(chain = true)
@ApiModel("用户信息(查询业务对象)")
public class UserInfoQueryBO extends BaseBO implements Serializable {
    private static final long serialVersionUID = 1L;





    /** 用户代码 */
    @ApiModelProperty(value = "用户代码")
    private String usercode;


    /** 用户名 */
    @ApiModelProperty(value = "用户名")
    private String username;


    /** 昵称 */
    @ApiModelProperty(value = "昵称")
    private String nickname;


    /** 系统角色;超级管理员:admin,普通用户：normal */
    @ApiModelProperty(value = "系统角色;超级管理员:admin,普通用户：normal")
    private String sysRole ;


    /** 角色ID */
    @ApiModelProperty(value = "角色ID")
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Long roleId;


    /** 拼音 */
    @ApiModelProperty(value = "拼音")
    private String pinyin;


    /** 密码 */
    @ApiModelProperty(value = "密码")
    private String password;


    /** 用户类型 */
    @ApiModelProperty(value = "用户类型")
    private String usertype;


    /** 邮箱 */
    @ApiModelProperty(value = "邮箱")
    private String email;


    /** 电话 */
    @ApiModelProperty(value = "电话")
    private String mobile;


    /** QQ号 */
    @ApiModelProperty(value = "QQ号")
    private String qq;


    /** 微信号 */
    @ApiModelProperty(value = "微信号")
    private String weixin;


    /** 主题 */
    @ApiModelProperty(value = "主题")
    private String theme;


    /** 头像 */
    @ApiModelProperty(value = "头像")
    private String avatar;


    /** 描述 */
    @ApiModelProperty(value = "描述")
    private String description;


    /** 最近登录时间 */
    @ApiModelProperty(value = "最近登录时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date lastlogintime;


    /** 扩展字段 */
    @ApiModelProperty(value = "扩展字段")
    private String jsonExt;


    /** 备用1 */
    @ApiModelProperty(value = "备用1")
    private String opt1;


    /** 备用2 */
    @ApiModelProperty(value = "备用2")
    private String opt2;


    /** 备用3 */
    @ApiModelProperty(value = "备用3")
    private String opt3;


    /** 省份代码 */
    @ApiModelProperty(value = "省份代码")
    private String procode;


    /** 用户状态;正常:normal,禁用:disabled */
    @ApiModelProperty(value = "用户状态;正常:normal,禁用:disabled")
    private String userState;











    /**
     * 根据QueryBO获取MP查询Wrapper包装器
     * @return
     */
    public LambdaQueryWrapper<UserInfoPO> getQueryWrapper(){
        if(Func.isEmpty(this)){
            throw new ServiceException(ResultEnum.PARAM_MISS,"构造查询Wrapper，入参不能为空！");
        }
        LambdaQueryWrapper<UserInfoPO> rsp = MpSqlWrapperUtils.buildQueryWrapper(this);
        rsp.eq(StringUtils.isNotBlank(this.getUsercode()), UserInfoPO::getUsercode, this.getUsercode());
        rsp.like(StringUtils.isNotBlank(this.getUsername()), UserInfoPO::getUsername, this.getUsername());
        rsp.like(StringUtils.isNotBlank(this.getNickname()), UserInfoPO::getNickname, this.getNickname());
        rsp.eq(StringUtils.isNotBlank(this.getSysRole()), UserInfoPO::getSysRole, this.getSysRole());
        rsp.eq(null != this.getRoleId(), UserInfoPO::getRoleId, this.getRoleId());
        rsp.like(StringUtils.isNotBlank(this.getPinyin()), UserInfoPO::getPinyin, this.getPinyin());
        rsp.eq(StringUtils.isNotBlank(this.getPassword()), UserInfoPO::getPassword, this.getPassword());
        rsp.like(StringUtils.isNotBlank(this.getUsertype()), UserInfoPO::getUsertype, this.getUsertype());
        rsp.like(StringUtils.isNotBlank(this.getEmail()), UserInfoPO::getEmail, this.getEmail());
        rsp.like(StringUtils.isNotBlank(this.getMobile()), UserInfoPO::getMobile, this.getMobile());
        rsp.like(StringUtils.isNotBlank(this.getQq()), UserInfoPO::getQq, this.getQq());
        rsp.like(StringUtils.isNotBlank(this.getWeixin()), UserInfoPO::getWeixin, this.getWeixin());
        rsp.like(StringUtils.isNotBlank(this.getTheme()), UserInfoPO::getTheme, this.getTheme());
        rsp.like(StringUtils.isNotBlank(this.getAvatar()), UserInfoPO::getAvatar, this.getAvatar());
        rsp.like(StringUtils.isNotBlank(this.getDescription()), UserInfoPO::getDescription, this.getDescription());
        rsp.eq(null != this.getLastlogintime(), UserInfoPO::getLastlogintime, this.getLastlogintime());
        rsp.like(StringUtils.isNotBlank(this.getJsonExt()), UserInfoPO::getJsonExt, this.getJsonExt());
        rsp.like(StringUtils.isNotBlank(this.getOpt1()), UserInfoPO::getOpt1, this.getOpt1());
        rsp.like(StringUtils.isNotBlank(this.getOpt2()), UserInfoPO::getOpt2, this.getOpt2());
        rsp.like(StringUtils.isNotBlank(this.getOpt3()), UserInfoPO::getOpt3, this.getOpt3());
        rsp.like(StringUtils.isNotBlank(this.getProcode()), UserInfoPO::getProcode, this.getProcode());
        rsp.like(StringUtils.isNotBlank(this.getUserState()), UserInfoPO::getUserState, this.getUserState());
        return rsp;
    }

}